#include "displaythread.h"
#include <QThread>
#include "xfccm2.h"
#include <QDebug>

DisplayThread::DisplayThread(int devID)
{
    bloopFlag=true;
    m_devID=devID;
}

void DisplayThread::closeThread()
{
    bloopFlag = false;
}

unsigned char* DisplayThread::getRgb24Buffer()
{
    return m_pRgb24Buffer;
}


void DisplayThread::pauseThread()
{
   pause.lock();
}
void DisplayThread::resumeThread()
{
   pause.unlock();
}

void DisplayThread::startThread()
{
    bloopFlag = true;
    while (bloopFlag)
    {
        pause.lock();
        if (xfGrabber != nullptr) {
            QImage image = xfGrabber->grabImage();
            if (!image.isNull()) emit displayLiveImage(image);
            QThread::msleep(1000);
        } else {
            qWarning("XF grabber is null.");
            QThread::msleep(3000);
        }
        pause.unlock();
    }
}
